import javax.swing.plaf.synth.SynthOptionPaneUI;
import java.util.Scanner;

public class Demo9 {
    public static void main(String[] args) {
        Thread t=new Thread(()->{
            while (!Thread.currentThread().isInterrupted()){
                System.out.println("hello Thread");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.println("t线程退出");
        });
        t.start();
        Scanner sc=new Scanner(System.in);
        System.out.println("用户输入0表示退出");
        int n= sc.nextInt();
        if(n==0){
            t.interrupt();
        }
    }
}
